<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1"/>
    <meta name="renderer" content="webkit">
    <title>工程机械设备信息平台</title>
    <link href="framework/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="css/main.css" rel="stylesheet"/>
    <style>
        #logincon{position:absolute;width:298px;top:10%;right:10%}
        #loginbottom{margin-top:5px;width: 100%}
        #form-login{width:244px;align:center;margin:auto}
        #loginDiv{position:relative;left:0px;top:0px;width:100%;z-Index:0}
        #sysname{height:30px;font-size:18px;color:#000000;text-align:center}
        #logindialog{background-color:rgba(255,255,255,0.6);border: rgba(104,104,104,0.2) solid 1px;border-radius: 8px;padding:10px;}
        #save_pwd_btn{color:#575757;background:url(img/s_no.png) left no-repeat;cursor:pointer;padding-left:25px;margin:0 40px 0 10px;}
        #save_pwd:checked+#save_pwd_btn{background:url(img/s_ok.png) left no-repeat}
    </style>
</head>
<body>
<div class="container-fluid">
    <div class="row">
        <img src="img/back1.jpg" width="100%" />
        <div id="logincon">
            <div id="sysname">工程机械设备信息平台</div>
            <div id="logindialog">
                <form id="form-login">
                    <div class="form-group">
                        <label>登录邮箱</label>
                        <input type="text" name="email"
                               class="form-control validate[required,custom[email]]"
                               placeholder="请输入登录邮箱" data-errormessage-value-missing="请输入登录邮箱"
                               data-errormessage-custom-error="邮箱格式应为:xxx...@xxxx.com"/>
                    </div>
                    <div class="form-group">
                        <label>登录密码</label>
                        <input type="password" name="password"
                               class="form-control validate[required,minSize[6],maxSize[18]]"
                               placeholder="请输入登录密码" data-errormessage-value-missing="请输入登录密码"
                               data-errormessage-range-underflow="密码少于6位"
                               data-errormessage-range-overflow="密码长度超出限制(18位)"/>
                    </div>
                    <div class="form-group">
                        <input type="checkbox" id="save_pwd" style="display: none" name="save" value="1"/>
                        <label for="save_pwd" id="save_pwd_btn" >记住密码</label>
                    </div>
                    <div class="form-group">
                        <button id="btn-login"
                                class="btn btn-block btn-primary" onclick="login()"
                                type="button">登录
                        </button>
                    </div>
                </form>
            </div>
        </div>
        <div id="loginbottom">
            <!--<div class="col-xs-3 col-xs-offset-7 text-center">-->
                <!--<img src="../../img/logo1.png"/>-->
                <!--<div class="" style="font-size:12px; color:#666666;">电话:400-808-1640&nbsp;传真:0731-88686789</div>-->
            <!--</div>-->
            <!--<div class="col-xs-1 text-center">-->
                <!--<img src="../../img/hc_wx.jpg" width="100%"-->
                     <!--style="border:1px solid #ccc"/>-->
                <!--<p style="font-size:12px">微信公众号</p>-->
            <!--</div>-->
            <!--<div class="col-xs-1 text-center">-->
                <!--<img src="../../img/app.png" width="100%"-->
                     <!--style="border:1px solid #ccc" />-->
                <!--<p style="font-size:12px">手机APP下载</p>-->
            <!--</div>-->
        </div>
    </div>
    <div id="mask">
        <img src="img/load.gif">
    </div>
<script src="framework/jquery/jquery-3.1.1.min.js"></script>
<script src="framework/validationEngine/jquery.validationEngine.min.js"></script>
<script src="framework/validationEngine/jquery.validationEngine-zh_CN.js" charset="utf-8"></script>
<script src="js/core.js"></script>
<script src="js/index.js" charset="utf-8"></script>
<script src="framework/toastr.min.js"></script>
<script type="text/javascript">
    $(function () {
       if (GetQueryString("logout")) {
            _clearStorage();
        } else {
            if (_getStorage("rember")){
                $("#save_pwd").prop("checked", true);
                $("[name='email']").val(_getStorage("email"));
                $("[name='password']").val(_getStorage("password"));
            }
        }
        callSvr("AccountManage/getIsLogin",{},function(ret){
            if(ret.err==0)window.location.href = "../../page/global/index.html";
        });
        $("input").keydown(function (e) {
            e = e || event;
            if (e.keyCode == 13) {
                login();
                return false;
            }
        });
        $("#form-login").validationEngine({
            promptPosition: 'topRight:-30',
            addPromptClass: 'formError-noArrow',
            maxErrorsPerField: 1
        });
    });
    function login() {
        var para = $("#form-login").formToJson();
        if ($("#form-login").validationEngine('validate')) {
            if ($('#save_pwd').is(":checked")) {
                _setStorage('rember', 1);
                _setStorage('email', $("[name='email']").val());
                _setStorage('password', $("[name='password']").val());
            } else {
                _removeStorage("rember");
                _removeStorage("email");
                _removeStorage("password");
            }
            callSvr("AccountManage/login",para,function(ret){
                switch (ret.err){
                    case 1:
                        toastr.error('账号或密码错误', '');
                        break;
                    case 2:
                        toastr.error('账号被禁用', '');
                        break;
                    case 0:
                        window.location.href="../../page/global/index.html";
                        break;
                    default:
                        break;
                }
            },true);
        }
    }
    function GetQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        return window.location.search.substr(1).match(reg);
    }
</script>
</body>
</html>

